Updated docs
[supercollider.git] / platform / mac / Standalone Resources / SCClassLibrary / SCSA_Demo.sc
blob8c7a6575dc401e1e5978eb97c800b5876682215d
1 SCSA_Demo : SCWindow {
3         classvar
4                 <width = 300,
5                 <height = 200,
6                 buttonWidth = 100,
7                 buttonHeight = 30;
9         var button, synth, server;
11         *new {
12                 |name, bounds, server|
13                 ^super.new(name, bounds).init(server);
14         }
16         init {
17                 |serverArg|
18                 server = serverArg;
20                 SynthDef(\demoSynth, {
21                         |gate = 1.0, out = 0|
22                         var env;
23                         env = EnvGen.kr(Env.adsr(0, 0, 1, 0), gate: gate, doneAction: 2);
24                         Out.ar(out, [SinOsc.ar(1000), SinOsc.ar(1500)] * env * 0.125);
25                 }).send(server);
27                 button = SCButton(this, Rect(
28                         (this.bounds.width - buttonWidth) * 0.5,
29                         (this.bounds.height - buttonHeight) * 0.5,
30                         buttonWidth,
31                         buttonHeight
32                 ));
33                 button.states = [
34                         ["Hit me!", Color.black, Color.gray],
35                         ["Make it stop!", Color.black, Color.red]
36                 ];
37                 button.action = {
38                         |theButton|
39                         theButton.value.switch(
40                                 1, { synth = Synth.new(\demoSynth, target: server) },
41                                 0, { synth.set(\gate, 0.0) }
42                         )
43                 };
44         }